from datetime import datetime

import numpy as np
from matplotlib import pyplot as plt
def calculate_polarization(beliefs_np):
    """
    计算每轮的极化度 (Pz)，返回形状为 (T,) 的数组

    参数:
        beliefs_np: NumPy数组，形状为 (N, T)，N是代理数，T是轮次数

    返回值:
        polarization_per_round: 每轮的极化度，形状为 (T,)
    """
    mean_belief_per_round = np.mean(beliefs_np, axis=0)  # 按轮次计算均值，形状(T,)
    polarization_per_round = np.mean((beliefs_np - mean_belief_per_round) ** 2, axis=0)  # 按轮次计算方差，形状(T,)
    return polarization_per_round


# def calculate_global_disagreement(adjacency_matrix, beliefs_np):
#     """
#     计算每轮的全局分歧度 (DG)，返回形状为 (T,) 的数组
#
#     参数:
#         adjacency_matrix: 邻接矩阵，形状为 (N, N)
#         beliefs_np: NumPy数组，形状为 (N, T)，N是代理数，T是轮次数
#
#     返回值:
#         dg_per_round: 每轮的全局分歧度，形状为 (T,)
#     """
#     N, T = beliefs_np.shape
#     dg_per_round = np.zeros(T)  # 初始化每轮的DG值
#
#     for t in range(T):  # 遍历每一轮
#         total_dg = 0.0
#         for i in range(N):  # 遍历每个代理
#             neighbors = np.where(adjacency_matrix[i] == 1)[0]  # 代理i的邻居
#             if len(neighbors) == 0:
#                 continue
#             # 计算代理i在第t轮与邻居的信念差异的均值
#             diff = np.mean(np.abs(beliefs_np[i, t] - beliefs_np[neighbors, t]))
#             total_dg += diff
#         dg_per_round[t] = total_dg  # 存储第t轮的DG值
#
#     return dg_per_round
def calculate_local_disagreement(adj_row, v_i, v_matrix):
    """
    计算单个节点的局部不一致性 (local disagreement, DG_i)
    :param adj_row: 邻接矩阵中对应节点的行，代表该节点的邻居连接情况
    :param v_i: 当前节点的观点值
    :param v_matrix: 所有节点的观点矩阵
    :return: 该节点的局部不一致性 DG_i
    """
    neighbor_indices = np.where(adj_row != 0)[0]
    num_neighbors = len(neighbor_indices)
    if num_neighbors == 0:
        return 0
    diff_squared_sum = np.sum((v_i - v_matrix[neighbor_indices]) ** 2)
    return diff_squared_sum / num_neighbors

def calculate_global_disagreement(adj_matrix, v_matrix):
    """
    计算全局不一致性 (Global Disagreement, DG)
    :param adj_matrix: 邻接矩阵，表示网络结构
    :param v_matrix: 所有节点的观点矩阵
    :return: 全局不一致性 DG
    """
    num_nodes = adj_matrix.shape[0]
    num_rounds = v_matrix.shape[1]
    global_disagreements = []
    for r in range(num_rounds):
        local_disagreements = []
        for i in range(num_nodes):
            v_i = v_matrix[i][r]
            adj_row = adj_matrix[i]
            local_dg = calculate_local_disagreement(adj_row, v_i, v_matrix[:, r])
            local_disagreements.append(local_dg)
        # 根据新公式计算每轮DG
        dg = (1 / (2 * num_nodes)) * np.sum(local_disagreements)
        global_disagreements.append(dg)
    return np.array(global_disagreements)

def calculate_nci(adjacency_matrix, beliefs_np):
    """
    计算每轮的归一化聚类指数 (NCI)，返回形状为 (T,) 的数组

    参数:
        adjacency_matrix: 邻接矩阵，形状为 (N, N)
        beliefs_np: NumPy数组，形状为 (N, T)，T >= 2

    返回值:
        nci_per_round: 每轮的NCI值，形状为 (T,)

    注意:
        - 如果 T < 2，无法计算相关系数，会抛出异常
        - 每个轮次的NCI是基于当前轮及之前所有轮次的数据计算的
    """
    N, T = beliefs_np.shape
    nci_per_round = np.zeros(T)

    for t in range(T):
        # 需要至少2轮数据计算相关系数
        if t < 1:
            nci_per_round[t] = 0.0  # 第0轮无法计算，设为0
            continue

        # 提取从第0轮到第t轮的信念值（形状 (N, t+1)）
        cumulative_beliefs = beliefs_np[:, :t + 1]

        nci_values = []
        for i in range(N):
            neighbors = np.where(adjacency_matrix[i] == 1)[0]
            if len(neighbors) == 0:
                nci_values.append(0.0)
                continue

            # 计算代理i与每个邻居的相关系数
            correlations = []
            for j in neighbors:
                r, _ = pearsonr(cumulative_beliefs[i, :], cumulative_beliefs[j, :])
                correlations.append(r)

            nci_values.append(np.mean(correlations))

        nci_per_round[t] = np.mean(nci_values)  # 存储第t轮的NCI

    return nci_per_round
# 示例：小世界模型
from scipy.stats import pearsonr
topic="信息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, -0.9, -1.0, -1.1, -1.0, -0.8, -0.7, -0.5, -0.6, -0.7, -0.8, -0.9, -1.0],
    [-0.3, -0.5, -0.5, -0.5, -0.3, -1.2, 0.0, -0.3, -0.1, -0.3, -0.3, -0.4, -1.2, -0.6, -0.8, -1.5, -0.7, -0.9, -1.1, -1.1, -1.2, -1.2, -1.2, -0.6, -0.3, -0.2, -1.1, -1.1, -1.1, -1.2],
    [0.8, -0.4, -0.5, -0.4, 0.0, -0.3, 0.0, 0.0, 0.0, 0.0, -0.3, -0.6, -1.1, -0.7, -0.5, 0.3, -0.6, -0.9, -1.2, -1.2, -1.3, -1.1, -0.2, -0.3, -1.2, -0.9, -1.2, -1.2, -1.2, -0.3],
    [1.2, 0.8, 0.5, 0.2, 0.3, 0.4, 0.5, 0.6, 0.3, 0.0, 0.2, 0.3, 0.2, 0.1, 0.0, 0.1, 0.2, 0.3, 0.2, 0.3, 0.4, 0.3, 0.1, 0.0, -0.1, -0.2, -0.3, -0.4, -0.5, -0.6],
    [1.1, -0.5, -0.3, -0.6, 0.0, 0.0, 0.0, 0.5, 0.0, -0.5, -0.1, -0.8, 0.5, -0.6, -0.3, -0.1, -0.2, -0.7, -1.1, -1.1, -1.2, -1.2, -0.1, -0.2, -0.8, -0.8, 0.2, -1.1, -1.1, -0.5],
    [1.3, -0.7, 0.5, 0.0, 0.6, 0.0, -0.2, 0.2, -0.2, -0.2, -0.2, -0.6, 0.3, -0.7, -0.5, -0.8, -0.8, 0.7, 0.8, 1.2, 0.8, 0.2, 0.5, -0.1, -0.9, 0.2, 0.1, 0.1, 0.3, 0.5],
    [1.8, 1.5, 1.2, 1.0, 1.2, 1.5, 1.8, 2.0, 2.0, 1.8, 1.7, 1.9, 1.7, 1.9, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0],
    [-1.2, -1.0, -0.5, 0.0, 0.3, 0.4, 0.3, 0.4, 0.6, 0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0.65, -0.5],
    [1.0, 0.6, 0.0, 0.3, 0.3, -0.3, 0.0, 0.3, 0.3, -0.5, -0.8, -0.7, -0.6, -0.2, 0.3, -1.0, -1.0, -0.5, -1.2, -1.5, -0.5, 0.0, -0.2, -0.4, -1.2, -1.2, -1.2, -1.2, -0.9, -1.2],
    [1.2, 1.2, 1.3, 0.0, 0.0, 0.0, -0.3, -0.7, -1.5, -0.7, -0.7, -0.6, -0.5, -0.5, -1.0, -1.0, -0.5, 0.0, -1.3, 0.0, -1.0, 0.0, -0.5, 0.0, -0.7, -0.7, -1.3, 0.3, -0.4, -0.9],
    [-0.5, 0.2, 0.5, 0.7, 1.0, 1.0, 0.7, 0.5, 0.3, 0.2, 0.1, 0.2, 0.1, 0.0, 0.0, -0.5, -0.5, -0.5, -0.7, -1.0, -1.0, -0.5, -0.6, -0.7, -0.7, -0.6, -0.7, -0.6, -0.5, -0.6],
    [0.8, 1.7, 1.0, 0.3, 0.0, 0.3, -0.2, -1.0, -0.5, -0.5, 0.0, -0.3, -0.3, -0.3, -1.0, 0.0, 0.3, 0.0, -1.2, -1.0, -1.0, -0.7, -0.6, -0.5, -0.8, -1.2, -0.8, -0.8, -1.1, 0.9],
    [0.9, 0.5, 0.8, 0.5, 0.0, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, -0.4, 0.3, 0.2, -0.3, 0.0, 0.0, 0.0, 0.0, 0.0, 0.9, 0.5, 0.5, -0.4, -1.1, 0.4, 0.3, 0.5, 0.5, 0.5],
    [1.2, 1.5, 1.8, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 1.4, 1.3, 1.2, 1.3, 1.5, 1.7, 1.8, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 1.8, 1.9, 2.0, 2.0, 2.0, 2.0],
    [0.7, 0.5, 0.6, 0.7, 1.0, 1.5, 1.8, 2.0, 2.0, 2.0, 1.8, 1.5, 1.2, 1.3, 1.4, 1.5, 1.3, 1.2, 1.2, 1.1,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1.1, 1.2, 1.3, 1.4, 1.5, 1.5, 1.5, 1.7, 1.8, 1.9, 1.8, 1.7, 1.6, 1.7, 1.8, 1.9, 1.8, 1.9, 1.8],
    [0.8, 1.0, 1.2, 1.3, 1.5, 1.3, 1.3, 1.5, 1.3, 1.2, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.7, 1.8, 1.9, 2.0, 1.9, 1.8, 1.7, 1.6, 1.7, 1.8, 1.9, 1.8, 1.7],
    [1.5, 1.6, 1.6, 1.7, 1.8, 1.9, 2.0, 2.0, 1.6, 1.4, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 1.9, 2.0, 2.0, 1.9, 1.8, 1.7, 1.6, 1.7, 1.7, 1.8, 1.8, 1.8, 1.8],
    [1.2, 1.4, 1.6, 1.8, 2.0, 2.0, 2.0, 2.0, 1.8, 1.6, 1.4, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 1.9, 1.8, 1.7, 1.6, 1.7, 1.8, 1.9, 2.0, 2.0, 2.0, 2.0]
]

beliefs_agents=delete_top
beliefs_np = np.array(beliefs_agents)  # 形状为 (30, 10)
adjacency_matrix_np=np.array(adjacency_matrix)
p = calculate_polarization(beliefs_np)
print(p.tolist())

g = calculate_global_disagreement(adjacency_matrix_np, beliefs_np)
print(g.tolist())

n = calculate_nci(adjacency_matrix_np, beliefs_np)
print(n.tolist())
turn=31#轮数+1
    # 设置中文字体（确保你的系统支持中文字体，否则会报错）
plt.rcParams['font.sans-serif'] = ['SimHei']  # 例如使用黑体
plt.rcParams['axes.unicode_minus'] = False  # 解决负号显示问题
    # 创建画布和子图
plt.figure(figsize=(12, 8))

    # 绘制极化度 (Pz)
plt.subplot(3, 1, 1)#子图1
plt.plot(range(1, turn), p, marker='o', linestyle='-', color='blue', label='极化度 (Pz)')
plt.xlabel('轮次')
plt.ylabel('极化度')
plt.title('极化度 (Pz) 随轮次变化')
plt.grid(True)
plt.legend()
plt.ylim(0, 2)  # 固定纵坐标范围

    # 绘制全局分歧度 (DG)
plt.subplot(3, 1, 2)#子图2
plt.plot(range(1, turn), g, marker='s', linestyle='--', color='red', label='全局分歧度 (DG)')
plt.xlabel('轮次')
plt.ylabel('分歧度')
plt.title('全局分歧度 (DG) 随轮次变化')
plt.grid(True)
plt.legend()
plt.ylim(0, 1)


    # 绘制归一化聚类指数 (NCI)
plt.subplot(3, 1, 3)#子图3
plt.plot(range(1, turn), n, marker='^', linestyle='-.', color='green', label='归一化聚类指数 (NCI)')
plt.xlabel('轮次')
plt.ylabel('NCI')
plt.title('归一化聚类指数 (NCI) 随轮次变化')
plt.grid(True)
plt.legend()
plt.ylim(0, 1)


    # 调整布局并显示
plt.tight_layout()
plt.savefig(f'指标变化趋势-{topic}.png', dpi=300)  # 保存为PNG图片
plt.show()

plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

    # 创建画布和坐标系
plt.figure(figsize=(12, 6))

    # 在同一坐标系中绘制三条曲线
plt.plot(range(1, turn), p, marker='o', linestyle='-', color='blue', label='极化度 (Pz)')
plt.plot(range(1, turn), g, marker='s', linestyle='--', color='red', label='全局分歧度 (DG)')
plt.plot(range(1, turn), n, marker='^', linestyle='-.', color='green', label='归一化聚类指数 (NCI)')
plt.ylim(0, 2)
    # 统一设置坐标轴和标签
plt.xlabel('轮次')
plt.ylabel('指标值')
plt.title('极化度、全局分歧度与NCI随轮次变化对比')

plt.grid(True)
plt.legend()
# 获取当前时间
now = datetime.now()
# 方法1：通过格式化字符串直接截断至分钟
current_minute_str = now.strftime("%Y-%m-%d %H:%M")
    # 调整布局并保存
plt.tight_layout()
plt.show()

# 提取第十列数据（索引为9）
column_10 = beliefs_np[:, 9]

# 计算区间边界
min_val = np.min(column_10)
max_val = np.max(column_10)
start = np.floor(min_val / 0.2) * 0.2
stop = np.ceil(max_val / 0.2) * 0.2
bins = np.arange(start, stop + 0.2, 0.2)

# 绘制直方图
plt.hist(column_10, bins=bins, edgecolor='black', alpha=0.7)
plt.xlabel('Value Intervals')
plt.ylabel('Frequency')
plt.title('Frequency Histogram of the 10th Column (Bin Width=0.2)')
plt.xticks(bins)  # 显示所有区间刻度
plt.grid(axis='y', linestyle='--', alpha=0.7)

plt.show()




